package cn.cjxy.service;

import cn.cjxy.domain.Account;
import cn.cjxy.mapper.AccountMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
@Service
public class AccountService {

    @Autowired
    private AccountMapper accountMapper;

    public List<Account> findAll() {
        return accountMapper.findAll();
    }

    /**
     * 转账
     *
     * @param accountId
     * @param toAccountId
     * @param money
     */
    public void transfer(Integer accountId, Integer toAccountId, Double money) {

        // 余额增加
        accountMapper.addMoney(toAccountId, money);

              // 模拟异常

        // 余额减少
        accountMapper.subMoney(accountId, money);
    }
}